package com.vgemv.jsutilitysdkdemo.module.List.WordLive;

import com.vgemv.jsutilitysdk.JsJsonManager.JsJsonManager;

import java.util.ArrayList;
import java.util.Map;

public class WordLiveModel {
    public String author;
    public String authorType;
    public String content;
    public Integer id;
    public ArrayList<String> materialPicUrl;
    public String materialType;
    public String materialUrl;
    private String publishDatetime;
    public Integer topFlag;
    public Integer wordLiveID;

    public String publishDate;
    public String publishTime;

    public void setPublishDatetime(String publishDatetime) {
        this.publishDatetime = publishDatetime;
        this.publishDate = publishDatetime.substring(0,10);
        this.publishTime = publishDatetime.substring(11,19);
    }

    public WordLiveModel(Map map) {
        author = (String)map.get("author");
        content = (String)map.get("content");
        id = (Integer)map.get("id");
        //MARK:这里要注意分割.
        String totalPicUrl = (String)map.get("materialPicUrl");
        if(totalPicUrl != null && totalPicUrl.length() > 0) {
            String[] arr_picUrl = totalPicUrl.split("\\|");
            if (arr_picUrl != null) {
                String json = JsJsonManager.toJson(arr_picUrl,false);
                materialPicUrl = (ArrayList<String>) JsJsonManager.fromJson(json,ArrayList.class);
            }
        }
        setPublishDatetime((String)map.get("publishDatetime"));
        wordLiveID = (Integer) map.get("wordLiveID");
    }
}
